﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlServerCe;
using System.Data;

namespace TekaMUD.Engine.Persistence
{
	public class WeatherStorage
	{
		public static EnvData LoadEnvironmentData(int envID, SqlCeConnection conn)
		{
			SqlCeCommand cmd = new SqlCeCommand("select * from weatherdata where ID = " + envID, conn);

			using (IDataReader r = cmd.ExecuteReader())
			{
				if(r.Read())
				{
					EnvData ret = new EnvData()
					{
						CurrentSeason = (Season)r["CurrentWeather"],
						CurrentWeatherType = (WeatherType)r["CurrentWeather"],
						PreviousWeatherType = (WeatherType)r["PreviousWeather"],
						WeatherDuration = (int)r["WeatherDuration"],
						WindDirection = (WindDirection)r["WindDirection"],
						WindStrength = (int)r["WindStrength"],
						WorldClock = (DateTime)r["WorldClock"]
					};

					return ret;

				}

				return null;
			}
		}
	}
}
